package com.cml.rpc.server;

import com.cml.rpc.publicinterface.BlogService;
import com.cml.rpc.publicinterface.UserService;

import java.util.ArrayList;
import java.util.Map;

/**
 * 服务端入口
 * @author cml
 * @create 2021/7/21 10:14
 */
public class RpcServer {
    public static void main(String[] args) {
        UserService userService = new UserServiceImpl();
        BlogService blogService = new BlogServiceImpl();
        ServiceProvider serviceProvider = new ServiceProvider();
        //添加服务实现类
        serviceProvider.putService(new ArrayList(){{
            add(userService);
            add(blogService);
        }});
        // 得到服务容器
        Map<String, Object> serviceProviderContainer = ServiceProvider.getServiceProvider();

        SimpleRpcServer simpleRpcServer = new SimpleRpcServer(serviceProviderContainer);
        simpleRpcServer.start(8877);
    }
}
